package com.cloudbroker.openapi.manage.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.HSBCPSVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.history.result.HistoryListResult;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.history.result.HistorySearchEngineStatus;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.HistoryRecordForm;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.business.HistoryT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

/**
 * Created by zhaojp18008 on 2016/5/9.
 */
@Controller
public class HistoryController {
    @Resource
    private HistoryT2BizService historyT2;

    /**
     * 历史查询
     * */
    @ResponseBody
    @RequestMapping("/func_history_record_list")
    @SaveLog(remark = "历史查询")
    public HistoryListResult historyRecordList(HttpServletRequest request , String jsonpcallback){
        HistoryRecordForm form = getSingleParameterMapForBody(request , HistoryRecordForm.class);
        return VOUtil.setJsonpResult(historyT2.historyRecordList(form), jsonpcallback);
    }
    
    /**
     * 数据库数据导入搜索引擎
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_history_import_searchengine")
    @SaveLog(remark = "搜索引擎数据导入")
    public HSBCPSBackVO funcImportSearchEngine(HttpServletRequest request , String jsonpcallback){
    	HSBCPSVO form = getSingleParameterMapForBody(request , HSBCPSVO.class);
        return VOUtil.setJsonpResult(historyT2.funcImportSearchEngine(form), jsonpcallback);
    }
    
    /**
     * 搜索引擎状态获取
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_search_engine_status")
    @SaveLog(remark = "搜索引擎状态获取")
    public HistorySearchEngineStatus funSearchEngineStatus(HttpServletRequest request , String jsonpcallback){
    	HSBCPSVO form = getSingleParameterMapForBody(request,HSBCPSVO.class);
    	return VOUtil.setJsonpResult(historyT2.funSearchEngineStatus(form), jsonpcallback);
    }
}
